/**
 * 产品查看js
 */
var productInfoLook={
	dataCache:null,
	key:null,
	
	startEvent:function(){
		$("#recordTab ul").idTabs();
		productInfoLook.showInfoById();
	},
	
	showInfoById:function(){
		var id = art.dialog.data('lokId');
		productInfoLook.key = id+"_ProductType02_Key";
		
		var ret = eval('(' + localStorage.getItem(productInfoLook.key) + ')');
		for(var i in ret){
			var text=ret[i];
			if(i=='establishDate'||i=='onlineDate'||i=='endDate'||i=='releasesDate'|| i == 'proDividStartDate'|| i == 'proDividendDate'||i=='balanceDate'||i=='clearDate'||i=='discountEndDate'||i=='raiseBeginDate'||i=='raiseEndDate'){
				text=text==null?'':(new Date(text)).format('yyyy-MM-dd');
			}else if(i=='buyType'||i=='limitNum'||i=='saleType'||i=='prodType'||i=='publishType'||i=='riskLevel'||i=='currency'||i=='proStatus'||i=='buyChannel'||i=='divStartType'){
				
				text=jsUtils.getDictionaryTxtByType(i, text);
				if(i=='limitNum' && text ==''){
					text ="不限购";
				}
			}else if(i == 'isTest' ||i=='isParent'||i=='saleOut'||i=='isOversea'||i=='discount'||i=='hotSale'||i=='useCard'||i=='autStartDiv'||i=='startDiv' ||i=='directional'){
				text=(text==null?'':(text==0?'否':'是'));
			}else if(i=='startSaleTime'||i=='endSaleTime'||i=='saleOutTime'){
				text=(text==null?'':(new Date(text)).format('yyyy-MM-dd hh:mm:00'));
			}else if(i == 'agreements'){ //合同下拉多选框
				var agreements = "";
                $.each(text,function(index,value){
                    agreements +=" "+(index+1)+"、"+value.contractTitle+"；"
                });
                $("#agreements").html(agreements.substring(0,agreements.length-1));

			}else if(i=='clearDate'){
                text=(text==null?'':(new Date(text)).format('yyyy-MM-dd hh:mm:ss'));
			}else if(i == 'creditorType'){
                text=(text==0)? '个人':'企业';
			}
			$('#com-addForm td[name="'+i+'"]').html(text);
		}
		$('#introduceTxt').html((ret.introduceTxt==null?'':ret.introduceTxt));
		$('#product_description').html((ret.claimRecommendInfo == null ? '': ret.claimRecommendInfo));
		$('#incomeTxt').html((ret.incomeTxt==null?'':ret.incomeTxt));
		$('#riskctrlTxt').html((ret.riskctrlTxt==null?'':ret.riskctrlTxt));
		$('#signflowTxt').html((ret.signflowTxt==null?'':ret.signflowTxt));
	},
	
	init:function(){
		productInfoLook.startEvent();
	}
}
$(document).ready(function() {
	productInfoLook.init();
});